<?php
/**
 * 配置模型
 * 
 + ----------------------------------------------------- 
 * Date 2013-3-8
 + -----------------------------------------------------
 */
class ConfigModel extends CommonModel {

	protected $_validate = array(
		array('name','require','参数名称必须'),
		array('name','checkName','参数名称已经定义',0,'callback'),
	);

	protected $_auto		=	array(
		array('EMAIL_AUTH_PWD','pwdHash','callback',2),
	);

	public function checkName() {
		$map['name']	 =	 $_POST['name'];
        if(!empty($_POST['id'])) {
			$map['id']	=	array('neq',$_POST['id']);
        }
		$result	=	$this->find(array('where'=>$map,'field'=>'id'));
        if($result) {
        	return false;
        }else{
			return true;
		}
	}
	public function pwdHash(){
		return base64_encode($_POST['EMAIL_AUTH_PWD'].mt_rand(1000,9999));
	}
}
?>